package WaiBao;

import java.util.Arrays;

public class QingXiangYu {
    public static void main(String[] args) {
        String[] name = {"李静静(班长)", "王紫嫣(副班长)", "小李(学习委员)", "唐嫣(体育委员)", "李耀强", "李浩铭", "王宝钏", "李宝强", "李顺华", "李志强", "李汉生", "张东辉",
                "张海", "返疆", "张达", "张子枫", "刘先照", "张先生", "刘华强", "宋官", "丁棍", "李连铸", "吴彦祖", "吴奇隆", "李大宝", "张晓峰", "王大海", "魏庆宇",
                "李大宝", "秦祥宇(学生)"};//考生本人:秦祥宇(学生)
        int[] age = {20, 20, 18,22, 20, 21, 19, 21, 20, 21, 18, 22, 18, 21, 20, 19, 18, 18, 18, 18, 19, 19, 20, 20, 20, 19, 18, 21,22,19};//考生年龄：19


        double[] langzhu1 = {77, 75, 87, 81, 80, 78, 78, 84, 81, 74, 91, 67, 85, 74, 61, 78, 69, 69, 75, 88, 92, 91, 95, 85, 75, 74, 77, 86, 90, 95};
        double[] langzhu2 = {75, 65, 88, 84, 76, 71, 84, 79, 75, 80, 94, 65, 76, 84, 77, 62, 84, 68, 82, 75, 82, 71, 84, 87, 75, 84, 78, 65, 71, 95};
        double[] langzhu3 = {87, 84, 81, 75, 79, 94, 68, 89, 80, 60, 83, 87, 85, 65, 65, 68, 89, 67, 94, 83, 94, 81, 85, 85, 76, 84, 73, 86, 85, 95};


        double wulun1;//代表每个学生的总分
        double wulun2;//代表每个学生的平均分
//        for (int i = 0; i < 30; i++) {
//            wulun1 = langzhu1[i] +langzhu2[i] +langzhu3[i];
//            wulun2 = (wulun1 * 1.0) / 3;
//            System.out.println(name[i] + "的总分为:" + wulun1);
//            System.out.println(name[i] + "的平均分为:" +wulun2);
//        }


        double xingm1 = 0,xingm2 = 0;
        double[] arr = new double[30];
//        for (int i = 0; i < 30; i++) {
//            xingm1 = langzhu1[i] + langzhu2[i] + langzhu3[i];
//            xingm2  = (xingm1 * 1.0) / 3;
//            arr[i] = xingm2;
//        }
//
//        for (int i = 0; i < arr.length - 1; i++) {
//            for (int j = 0; j < arr.length - i - 1; j++) {
//                if (arr[j] < arr[j + 1]) {
//                    double tep = arr[j];
//                    arr[j] = arr[j + 1];
//                    arr[j + 1] = tep;
//                }
//            }
//        }
//        System.out.println("前十名同学的成绩为:");
//        for (int i = 0; i < 10; i++) {
//            System.out.println(arr[i]);
//        }



        double roke1 = 0, roke2 = 0, roke3 = 0;//计算每门课的平均分
        double bcd1 = 0, bcd2 = 0,bcd3 = 0;//计算每门课标准差
        double edg1 = 0, edg2 = 0,edg3 = 0;//计算每门课中位数
        double sum2 = 0;
        for (int i = 0; i < langzhu1.length; i++) {
            sum2+=langzhu1[i];
        }
        roke1 = (sum2*1.0)/30;
        System.out.println("农业设施及环境调控的班级平均分为:"+roke1);
        double Sum = 0;
        for (int i = 0; i < langzhu2.length; i++) {
            Sum+=langzhu2[i];
        }
        roke2 = (Sum*1.0)/30;
        System.out.println("农业设施设计与建造的班级平均分为:"+roke2);
        double sum = 0;
        for (int i = 0; i <langzhu3.length; i++) {
            sum+=langzhu3[i];
        }
        roke3 = (sum*1.0)/30;
        System.out.println("园艺植物设施栽培学的班级平均分为:"+roke3);



        double c1 = 0,c2 = 0,c3 = 0;
        for (int i = 0; i < langzhu1.length; i++) {
            c1+= (langzhu1[i] -roke1)*(langzhu1[i] - roke1);
        }
        bcd1 = Math.sqrt(c1*1.0/30);
        System.out.println("农业设施及环境调控的班级标准差为:"+bcd1);

        for (int i = 0; i <langzhu2.length; i++) {
            c2+= (langzhu2[i] -roke2)*(langzhu2[i] - roke2);
        }
        bcd2 = Math.sqrt(c2*1.0/30);
        System.out.println("农业设施设计与建造的班级标准差为:"+bcd2);

        for (int i = 0; i < langzhu3.length; i++) {
            c3+= (langzhu3[i] -roke3)*(langzhu3[i] - bcd3);
        }
        bcd3 = Math.sqrt(c3*1.0/30);
        System.out.println("园艺植物设施栽培学的班级标准差为:"+bcd3);
//////////
        Arrays.sort(langzhu1);
        Arrays.sort(langzhu2);
        Arrays.sort(langzhu3);
        edg1 =( langzhu1[15]+langzhu1[14])*1.0/2;
        edg2 =( langzhu2[15]+langzhu2[14])*1.0/2;
        edg3 =(langzhu3[15]+langzhu3[14])*1.0/2;
        System.out.println("农业设施及环境调控的中位数为:"+edg1);
        System.out.println("业设施设计与建造的中位数为:"+edg2);
        System.out.println("园艺植物设施栽培学的中位数为:"+edg3);




    }
}
